# Contributor: Celeste <cielesti@protonmail.com>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=emacs-vterm
pkgver=0_git20240324
_gitrev=ae4ae1aef2fcae98a37aad83f2a6aeeaeacedd4f
pkgrel=0
_pkgreal=vterm
pkgdesc="Fully-fledged terminal emulator based on libvterm"
url="https://github.com/akermu/emacs-libvterm"
arch="all"
license="GPL-3.0-or-later"
depends="cmd:emacs"
makedepends="
	cmake
	emacs-nox
	libvterm-dev
	ninja
	"
source="https://github.com/akermu/emacs-libvterm/archive/$_gitrev/emacs-vterm-$_gitrev.tar.gz"
builddir="$srcdir/emacs-libvterm-$_gitrev"
options="!check" # tests just run the terminal emulator for you to try out

prepare() {
	default_prepare

	# use system header file
	rm -v emacs-module.h
}

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DUSE_SYSTEM_LIBVTERM=ON \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_BUILD_TYPE=None
	cmake --build build

	emacs -batch -q -no-site-file -L . \
		-f batch-byte-compile \
		./*.el
}

package() {
	install -Dvm644 ./*.el ./*.elc vterm-module.so \
		-t "$pkgdir"/usr/share/emacs/site-lisp/

	cd "$pkgdir"/usr/share/emacs/site-lisp
	emacs -batch -q -no-site-file \
		-eval "(loaddefs-generate \".\" \"$_pkgreal-loaddefs.el\")"
}

sha512sums="
8afa2f93aa922e143ff7366a99a66a32e7fec41bae8cb71522d1e6bbca5e0130886b60c560c294ceb655fd83a79e5ef35bd513793a3c2b4f6e71a262353ad8f9  emacs-vterm-ae4ae1aef2fcae98a37aad83f2a6aeeaeacedd4f.tar.gz
"
